// map
Array.prototype.myMap = function (cb) {
    let arr = [];
    for (let i = 0; i < this.length; i++) {
        arr.push(cb.call(this, this[i], i, this))
    }
    return arr
}
// reduce
Array.prototype.myReduce = function (cb, initValue) {
    let acc = initValue ? initValue : this[0];
    for (let i = 0; i < this.length; i++) {
        let _this = this
        acc = cb(acc, this[i], i, _this)
    }
    return acc;
}
// flat 有递归
Array.prototype.myFlat = function (num = 1) {
    if (Array.isArray(this)) {
        let arr = [];
        if (!num || num < 0) return this;
        this.forEach((item) => {
            if (Array.isArray(item)) {
                let count = num;
                arr = arr.concat(item.myFlat(count--))
            } else {
                arr.push(item)
            }
        })
        return arr
    } else {
        throw Error("error")
    }
}
// 判断类型
Array.prototype.myIsArray = function (obj) {
    Object.prototype.toString.call(Object(obj)) == "[Object Array]"
}

